With the help of animate () method we can create animation effects on html page .In this article I am using animate method to give animation effect on image. It means image height and width will be resized when mouse pointer will over on image as shown below:
Code:
<head>
<title>Animate</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$("div").mouseover(function()//mouseover function will execute when mouse pointer will reach on <div>element
{
$("img").animate({ height: 300 }, "slow");//image height will change by using animate method
$("img").animate({ width: 300 }, "slow");
$("img").animate({ height: 100 }, "slow");
$("img").animate({ width: 100 }, "slow
});
}
);
</script>
</head>
<body>
<div style=" height:100px;width:100px;position:relative"> <img src="Lighthouse.jpg" id="img" style=" height:100px;width:100px;position:relative" </div>
</body>
</html>
Screenshot
Image height and width will change when mouse pointer will over on image as shown below:
Anonymous User
15-Apr-2019Thank You for sharing.